from django.conf.urls import url, include
from . import views
from rest_framework import routers

urlpatterns = [
    # url(r'^books/$', views.BookInfoView.as_view()),
    # url(r'^books/(?P<pk>\d+)/$', views.BookInfoDetailView.as_view()),
    # url(r'^model_view_set/$', views.BookModelViewSet.as_view({'get': 'list', "post": "create"})),
    # url(r'^model_view_set/(?P<pk>\d+)/$',
    #     views.BookModelViewSet.as_view({'get': 'retrieve', "put": "update", "delete": "destroy"}))

]
router = routers.SimpleRouter()
router.register(r'books', views.BookModelViewSet, base_name='book')

urlpatterns += router.urls
# for i in urlpatterns:
    # <RegexURLPattern haha-list ^books/$>
    # <RegexURLPattern haha-detail ^books/(?P<pk>[^/.]+)/$>
    # print(i)
# rout/er = defaultrouter()
# 打印出来如下
# [
# <RegexURLPattern haha-list ^book/$>,
# <RegexURLPattern haha-list ^book\.(?P<format>[a-z0-9]+)/?$>,
#
# <RegexURLPattern haha-detail ^book/(?P<pk>[^/.]+)/$>,
# <RegexURLPattern haha-detail ^book/(?P<pk>[^/.]+)\.(?P<format>[a-z0-9]+)/?$>,
#
# <RegexURLPattern api-root ^$>,
# <RegexURLPattern api-root ^\.(?P<format>[a-z0-9]+)/?$>
# ]